package com.itjiange.controller.user;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 退出登录
 *
 * @author ItJiange
 * @date 2023/10/23
 */
@WebServlet("/user/loginOut")
public class UserLoginOutController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        session.removeAttribute("user");
        Object user = session.getAttribute("user");
        if (user == null) {
            PrintWriter writer = resp.getWriter();
            writer.write("nullStatus");
            writer.flush();
            writer.close();
        }
    }
}
